package EXP2_Image;


import EXP2_Image.Factory.*;
import java.util.Scanner;
/**
 * @author Liweijian.
 * @Description TODO
 * @date 2025/3/18 15:22
 */

// 测试程序
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要读取的图片格式（GIF 或 JPG）：");
        String format = scanner.nextLine().toUpperCase();
        ImageReaderFactory factory;

        try {
            switch (format) {
                case "GIF":
                    factory = new GifReaderFactory();
                    break;
                case "JPG":
                    factory = new JpgReaderFactory();
                    break;
                default:
                    throw new IllegalArgumentException("不支持的图片格式：" + format);
            }
            ImageReader reader = factory.getImageReader();
            reader.readImage();
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        } finally {
            scanner.close();
        }
    }
}
